package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

/**
 * Class is responsible for logger dynamic update in dynamic mode.
 */
public class LoggerDynamicAction implements ActionListener 
{
	/**
	 * Timer for logger dynamic update
	 */
	public Timer timer = null;
	
	/**
	 * C'tor - initialize the timer.
	 */
	public LoggerDynamicAction()
	{
		timer = new Timer(1000, this);
	}

	/**
	 * Stops timer work.
	 */
	public void stop()
	{
		timer.stop();
	}
	
	/**
	 * For each timer tick rebuild two logger tables (update their data).
	 */
	public void actionPerformed(ActionEvent event)
	{
		LoggerTable.currentLoggerTable.buildTable();
		LoggerGlobalTable.currentLoggerGlobalTable.buildTable();
	}

	/**
	 * Starts timer work.
	 */
	public void start()
	{
		timer.start();		
	}
}
